package io.github.biezhi.wechat.utils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wangsh
 * @date 2019-07-05 22:15
 */
public class FFmpegUtils {

    private static final String FFMPEG_PATH = "/usr/bin/ffmpeg";

    public static void convertPcmVoice(String srcVoicePath, String tarVoicePath) {
        List<String> commend = new ArrayList<>();
        commend.add(FFMPEG_PATH);
        commend.add("-y");
        commend.add("-i");
        commend.add(srcVoicePath);
        commend.add("-acodec");
        commend.add("pcm_s16le");
        commend.add("-f");
        commend.add("s16le");
        commend.add("-ac");
        commend.add("1");
        commend.add("-ar");
        commend.add("16000");
        commend.add(tarVoicePath);

        ProcessBuilder builder = new ProcessBuilder();
        builder.command(commend);
        try {
            builder.start();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
